/*
 * @Author: 噜噜雯雯 2199987619@qq.com
 * @Date: 2025-06-09 09:49:40
 * @LastEditors: 噜噜雯雯 2199987619@qq.com
 * @LastEditTime: 2025-07-08 08:53:08
 * @FilePath: \linePatrol\vue-element-plus-admin\src\store\modules\plangroup.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { defineStore } from 'pinia'
import { store } from '../index'
import { DeptListType } from '@/api/dept/type'
import DeptApi from '@/api/dept'
import { flatData } from '@/hooks/PublicFun'

export const useDeptStore = defineStore('deptstore', {
  state: () => {
    return {
      DeptListTypeDetail: [] as unknown as DeptListType[]
    }
  },
  getters: {
    //根据id返回部门 模糊查询
    getDeptName:
      (state) =>
      (id: number | any): any[] => {
        const i = flatData(state.DeptListTypeDetail).filter((item) => {
          return item.deptId == id
        })
        return i
      }
  },
  actions: {
    async setFacilityTypeDetail() {
      this.DeptListTypeDetail = await DeptApi.GetDeptList({})
    },
    persist: true
  }
})

export const useLockStoreWithOut = () => {
  return useDeptStore(store)
}
